{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "tags": [
     "remove-cell"
    ]
   },
   "outputs": [],
   "source": [
    "import sys\n",
    "import os\n",
    "if not any(path.endswith('textbook') for path in sys.path):\n",
    "    sys.path.append(os.path.abspath('../../..'))\n",
    "from textbook_utils import *"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "(ch:fake_news)=\n",
    "# Case Study: Detecting Fake News"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "_Fake news_---false information created in order to deceive others---is an\n",
    "important issue because it can harm people.\n",
    "For example, the social media post in\n",
    "{numref}`Figure %s <fig:dont-use-sanitizer>`\n",
    "confidently stated that hand sanitizer doesn't work on coronaviruses.\n",
    "Though factually incorrect, it spread through social media anyway:\n",
    "it was shared nearly 100,000 times and was likely seen by millions of people."
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```{figure} figures/dont-use-sanitizer.png\n",
    "---\n",
    "name: fig:dont-use-sanitizer\n",
    "scale: 40%\n",
    "---\n",
    "\n",
    "A popular post on Twitter from March 2020 falsely claimed that sanitizer doesn't kill coronaviruses\n",
    "```"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We might wonder whether we can automatically detect fake news without having to read the stories. \n",
    "For this case study, we go through the steps of the data science lifecycle.\n",
    "We start by refining our research question and obtaining a dataset of news\n",
    "articles and labels.\n",
    "Then we wrangle and transform the data.\n",
    "Next, we explore the data to understand its content and\n",
    "devise features to use for modeling.\n",
    "Finally, we build models using logistic regression to predict whether news articles are real or fake, and evaluate their performance."
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We've included this case study because it lets us reiterate several important\n",
    "ideas in data science.\n",
    "First, natural language data appear often, and even basic techniques can enable\n",
    "useful analyses.\n",
    "Second, model selection is an important part of data analysis, and in this case\n",
    "study we apply what we've learned about cross-validation, the bias–variance trade-off, and regularization.\n",
    "Finally, even models that perform well on the test set might have inherent\n",
    "limitations when we try to use them in practice, as we will soon see."
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's start by refining our research question and understanding the scope of\n",
    "our data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
